﻿<!--#include file="../inc/easp/easp.asp"-->
<!--#include file="../inc/conn1.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<!--#include file="../inc/easyide.asp"-->
<% CheckLogin("../index.asp") %>
<%
    '鏉冮檺涓嶅鐩存帴璺冲埌棣栭〉
	If Session("Authority")<>"0" Then
		Response.Write "<script type=""text/javascript"">top.location.href='../main.asp';</script>"
	end if				
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  <%
    
		  Easp.w "Add Country"
		
  %>
</title>
<link rel="stylesheet" type="text/css" href="../css/theme.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript">
	var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
	document.writeln('<link rel="stylesheet" type="text/css" href="../css/' + StyleFile + '">');
	
	function chkv(obj)
    { 
        var txtCountryName=document.getElementById("txtCountryName");
        var holidays=document.getElementById("txtHolidaysName");
        
         var Board1=document.getElementById("txtWellBoard1");
         var Board2=document.getElementById("txtWellBoard2");
         var Board3=document.getElementById("txtWellBoard3");
         var Url1=document.getElementById("txtWellBoardUrl1");
         var Url2=document.getElementById("txtWellBoardUrl2");
         var Url3=document.getElementById("txtWellBoardUrl3");


        top.location.href="AddCountry.asp?action=custom&selectedIndex="+oobj.options[obj.selectedIndex].value+"&CountryName="+txtCountryName.value+"&holidays="+holidays.value   +"&Board1="+Board1.value+"&Board2="+Board2.value+"&Board3="+Board3.value+"&Url1="+escape(Url1.value)+"&Url2="+escape(Url2.value)+"&Url3="+escape(Url3.value);
        
        //alert("AddCountry.asp?action=custom&selectedIndex="+obj.selectedIndex+"&CountryName="+txtCountryName.value);
    } 
    
    function Add()
    { 
        var txtCountryName=document.getElementById("txtCountryName");
        var obj=document.getElementById("group");
        var holidays=document.getElementById("txtHolidaysName");
         var Board1=document.getElementById("txtWellBoard1");
         var Board2=document.getElementById("txtWellBoard2");
         var Board3=document.getElementById("txtWellBoard3");
         var Url1=document.getElementById("txtWellBoardUrl1");
         var Url2=document.getElementById("txtWellBoardUrl2");
         var Url3=document.getElementById("txtWellBoardUrl3");
         
        if (txtCountryName.value == "")
	    {		
		    obj["txtCountryName"].focus();
		    return false;
	    }
        if (holidays.value == "")
	    {		
		    obj["txtHolidaysName"].focus();
		    return false;
	    }
        top.location.href='AddCountry.asp?action=submit&selectedIndex='+obj.options[obj.selectedIndex].value+"&CountryName="+txtCountryName.value+"&holidays="+holidays.value   +"&Board1="+Board1.value+"&Board2="+Board2.value+"&Board3="+Board3.value+"&Url1="+escape(Url1.value)+"&Url2="+escape(Url2.value)+"&Url3="+escape(Url3.value);
    } 
</script>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>
<body>
<div id="container">
	<div id="header">
    <div id="divAccount" style="float:right;">
        <a href="../user/account.asp" style="color:white">Account</a>&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="../inc/logout.asp" style="color:white">Logout</a>
      </div>
		<h2>
	<%    
		  Easp.w "Add Country"		
  %>
  </h2>
		<div id="topmenu">
			<ul>
				<li><a href="../main.asp">Home</a></li>
				<li class="current"><a href="#">Country</a></li>
				<li><a href="../holiday/index.asp">Holiday</a></li>
				<li><a href="../Times/index.asp">Times</a></li>
				<li><a href="../wallboard/index.asp">WallBoard</a></li>
				<%
				   If Session("Authority")="0" Then 
				       Response.Write("<li><a href='../user/index.asp'>User</a></li>")
				   End if
				%>
				<li><% If Session("Passed")=true Then %><a href="../inc/logout.asp">Logout</a><% End If %></li>
			</ul>
		</div>
	</div>
	<div id="top-panel">
		<div id="panel">
			<ul>
				<li><a href="<%=request.serverVariables("Http_REFERER")%>" class="goback">GoBack</a></li>
			</ul>
		</div>
	</div>
	<div id="wrapper">
		<%

		dim relt

	    dim HolidayFile
	    dim TimesFile
	    
	    dim countryname
        dim holidaysname
	    dim groupname
	    dim selectedIndex

        dim WellBoard3
	    dim WellBoard2
	    dim WellBoard1
	    dim WellBoardUrl3
	    dim WellBoardUrl2
	    dim WellBoardUrl1
Function vbsEscape(str)'加密 
                dim i,s,c,a 
                s="" 
                For i=1 to Len(str) 
                    c=Mid(str,i,1) 
                    a=ASCW(c) 
                    If (a>=48 and a<=57) or (a>=65 and a<=90) or (a>=97 and a<=122) Then 
                        s = s & c 
                    ElseIf InStr("@*_+-./",c)>0 Then 
                        s = s & c 
                    ElseIf a>0 and a<16 Then 
                        s = s & "%0" & Hex(a) 
                    ElseIf a>=16 and a<256 Then 
                        s = s & "%" & Hex(a) 
                    Else 
                        s = s & "%u" & Hex(a) 
                    End If 
                Next 
                vbsEscape = s 
            End Function

             

            Function vbsUnEscape(str)'解密 
                dim i,s,c 
                s="" 
                For i=1 to Len(str) 
                    c=Mid(str,i,1) 
                    If Mid(str,i,2)="%u" and i<=Len(str)-5 Then 
                        If IsNumeric("&H" & Mid(str,i+2,4)) Then 
                            s = s & CHRW(CInt("&H" & Mid(str,i+2,4))) 
                            i = i+5 
                        Else 
                            s = s & c 
                        End If 
                    ElseIf c="%" and i<=Len(str)-2 Then 
                        If IsNumeric("&H" & Mid(str,i+1,2)) Then 
                            s = s & CHRW(CInt("&H" & Mid(str,i+1,2))) 
                            i = i+2 
                        Else 
                            s = s & c 
                        End If 
                    Else 
                        s = s & c 
                    End If 
                Next 
                vbsUnEscape = s 
            End Function
	    'dim a
	    'a =request.QueryString("action")
	    
	    'response.write("<Script language=JavaScript>alert('"&a&"');</Script>")
	    
	    if request.QueryString("action")="custom" then
	    

             selectedIndex=request.QueryString("selectedIndex")
            holidaysname=request.QueryString("holidays")
            
	        countryname=request.QueryString("CountryName")
	        
	        WellBoard3=request.QueryString("Board3")
	     WellBoard2=request.QueryString("Board2")
	     WellBoard1=request.QueryString("Board1")
	    WellBoardUrl3=vbsUnEscape(request.QueryString("Url3"))
	     WellBoardUrl2=vbsUnEscape(request.QueryString("Url2"))
	     WellBoardUrl1=vbsUnEscape(request.QueryString("Url1"))
	     
	        'response.write("<Script language=JavaScript>alert('selectedIndex:"&request.QueryString("selectedIndex")&"');</Script>")
	        
	        'response.write("<Script language=JavaScript>alert('countryname:"&countryname&"');</Script>")
	        'response.write("<Script language=JavaScript>alert('selectedIndex:"&selectedIndex&"');</Script>")
	    elseif request.QueryString("action")="submit" then
	     
	    
            'page=request.QueryString("page")
            'response.write("<Script language=JavaScript>alert('"&page&"');</Script>")

                dim rscountry
			     
			     countryname= request.QueryString("CountryName")
			     holidaysname=request.QueryString("holidays")
			     selectedIndex=Cint(request.QueryString("selectedIndex"))
			     
			     WellBoard3=request.QueryString("Board3")
	             WellBoard2=request.QueryString("Board2")
	             WellBoard1=request.QueryString("Board1")
	             WellBoardUrl3=vbsUnEscape(request.QueryString("Url3"))
	     WellBoardUrl2=vbsUnEscape(request.QueryString("Url2"))
	     WellBoardUrl1=vbsUnEscape(request.QueryString("Url1"))
	     
			     HolidayFile=""
	             TimesFile=""
			     
			     response.write("<Script language=JavaScript>alert('"&WellBoard3&"');</Script>")
			     response.write("<Script language=JavaScript>alert('"&WellBoard2&"');</Script>")
			      response.write("<Script language=JavaScript>alert('"&WellBoard1&"');</Script>")
			     response.write("<Script language=JavaScript>alert('"&WellBoardUrl3&"');</Script>")
			      response.write("<Script language=JavaScript>alert('"&WellBoardUrl2&"');</Script>")
			     response.write("<Script language=JavaScript>alert('"&WellBoardUrl1&"');</Script>")
			     '插入国家表
		         relt=Easp.db.AddRecord("Country",Array("g_id:"&selectedIndex,"CountryName:"&countryname,"HolidayFile:"&HolidayFile,"TimesFile:"&TimesFile,"HolidayNum:"&holidaysname,"WallBoardName3:"&WellBoard3,"WallBoardName2:"&WellBoard2,"WallBoardName1:"&WellBoard1,"WallBoardValue3:"&WellBoardUrl3,"WallBoardValue2:"&WellBoardUrl2,"WallBoardValue1:"&WellBoardUrl1))
		         
		         '查询刚插入的国家号
		         'rscountry=Easp.db.GetRecordBySQL("Select max(y_id) as id  From Country")
		         
		         'if Not Easp.IsN(rscountry) Then
		           ' yid=rscountry("id")
		         'end if
		        ' response.write("<Script language=JavaScript>alert('"&page&"');</Script>")
		         '插入组国家关系表
		         'relt=Easp.db.AddRecord("GroupCountry",Array("GroupID:"&gid,"CountryID:"&yid))
		         
		        Response.Redirect "index.asp"

			If relt<>0 Then
				 response.write("<Script language=JavaScript>alert('Add  Succeed');</Script>")
			else
				 response.write("<Script language=JavaScript>alert('Add  Failed');</Script>")
			End If     
	    end if    
		
		%>
		<div id="content" align="center">	
				<div id="loginbox" align="center" style="margin: 10px 45px; width: 496px;">		
				 <div id="divCountry"  name="divCountry">			
					<form name="form1" id="form4" action="addcountry.asp?action=custom" method="post">
					

					  <br/>
					  
					    <table>
					    <tr>
						  <td width="228">
						    Group Name:
						  </td>
						  <td>
					         <% 
                           dim rsgroup,sql
                           
                         
                           
                           'if request.QueryString("selectedIndex")<> "" then
                             selectedIndex=Trim(request.QueryString("selectedIndex"))
                            
                           'end if
                         
                           
                           set rsgroup= Easp.db.GetRecordBySQL("SELECT Group.ID, Group.GroupName FROM [Group] where 1=1 ") 
    					   
    					   dim count
    					   count=0
    					   dim countgroupid
                           If Not Easp.IsN(rsgroup) Then
                               Easp.wc "<br/>"
                               Easp.wc "<select name='group' id='group'  id='group' style='width:155px;' onchange='chkv(this)'>"
                               While not rsgroup.eof
                               
                                      
                                      If  CStr(selectedIndex) <> CStr("") then
                                            'Response.write("<Script language=JavaScript>alert('selectedIndex:"&selectedIndex&"');</Script>") 
                                            'Response.write("<Script language=JavaScript>alert('rsgroup:"&rsgroup("ID")&"');</Script>")
                                             'Response.write("<Script language=JavaScript>alert('selectedIndex:"&selectedIndex&"');</Script>") 
                                             
                                            If (CStr(rsgroup("ID"))=CStr(selectedIndex)) then
 
                                                Easp.wc "<option value='" & rsgroup("ID") & "' selected='selected'>"& rsgroup("GroupName") &"</option>"
                                            Else
                                                'Response.write("dd") 
                                                'Easp.wc "<option value='" & rsgroup("ID") & "' selected='selected'>"& rsgroup("GroupName") &"</option>"
                                                Easp.wc "<option value='" & rsgroup("ID") & "'>"& rsgroup("GroupName") &"</option>"
                                            End if
                                        
                                      Else
                                            if(count<>1) then
                                           
                                                countgroupid=rsgroup("ID")
                                                 count=count+1
                                            end if
                                           
                                      
                                        Easp.wc "<option value='" & rsgroup("ID") & "'>"& rsgroup("GroupName") &"</option>"
                                      End if

						  	          rsgroup.MoveNext()
					           Wend
					           Easp.wc "</select>"
					          
                           End if        
                      %>
						  </td>
						</tr>
					      <tr>
							  <%
								    Easp.w "<td>Country Name:</td>"
									Easp.w "<td><input name='txtCountryName' type='text'  value='' id='txtCountryName' /></td>"
													      
							  %>						    
						  </tr>						  
 <tr>
							  <%
								    Easp.w "<td>Holidays Number:</td>"
									Easp.w "<td><input name='txtHolidaysName' type='text'  value='' id='txtHolidaysName' /></td>"
													      
							  %>						    
						  </tr>	
						 <tr>
							  <%
								    Easp.w "<td>Well Board one name:</td>"
									Easp.w "<td><input name='txtWellBoard1' type='text'  value='' id='txtWellBoard1' /></td>"
													      
							  %>						    
						  </tr>		
						   <tr>
							  <%
								    Easp.w "<td>Well Board one address:</td>"
									Easp.w "<td><input name='txtWellBoardUrl1' type='text'  value='' id='txtWellBoardUrl1' /></td>"
													      
							  %>						    
						  </tr>		
						  
						  <tr>
							  <%
								    Easp.w "<td>Well Board two name:</td>"
									Easp.w "<td><input name='txtWellBoard2' type='text'  value='' id='txtWellBoard2' /></td>"
													      
							  %>						    
						  </tr>	
						  	  <tr>
							  <%
								    Easp.w "<td>Well Board two address:</td>"
									Easp.w "<td><input name='txtWellBoardUrl2' type='text'  value='' id='txtWellBoardUrl2' /></td>"
													      
							  %>						    
						  </tr>	
						  
						  <tr>
							  <%
								    Easp.w "<td>Well Board three name:</td>"
									Easp.w "<td><input name='txtWellBoard3' type='text'  value='' id='txtWellBoard3' /></td>"
													      
							  %>						    
						  </tr>	
						  	  <tr>
							  <%
								    Easp.w "<td>Well Board three address:</td>"
									Easp.w "<td><input name='txtWellBoardUrl3' type='text'  value='' id='txtWellBoardUrl3' /></td>"
													      
							  %>						    
						  </tr>	

						  <tr>
						      <%
                                    'Easp.w "<td><input class='btn' type='submit' value='Save' /></td>"
                                     Easp.wc "<td><input id='add' name='add' type='button' class='btn' value='Add' onclick='Add()'/></td>"
						            Easp.w "<td><input id='reset' name='reset' type='reset' class='btn' value='Reset' /></td>"
							  %>
						  </tr>
					    </table>					    
					  </div>
					</form>	     
				</div>      
	</div>
	<!--#include file="../inc/footer.asp" -->
</div>

</body>
</html>
